package com.ai.bitcoin.jpa.dao;

import com.ai.bitcoin.jpa.entity.BccUserBonusLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

public interface BccUserBonusLogDao extends JpaRepository<BccUserBonusLog, String>, JpaSpecificationExecutor<BccUserBonusLog> {

    Long countByTotalKey(String totalKey);

    /**
     * 是否已发放奖励
     *
     * @param uniqueKey 奖励唯一KEY
     * @return true 已发 false 未发
     */
    boolean existsByUniqueKey(String uniqueKey);

    long deleteByOpenId(String openId);

    void deleteByUniqueKeyLike(String s);

//    /**
//     * 时间范围内 奖励领取次数
//     *
//     * @param openId   openId
//     * @param dateFrom 开始时间
//     * @param dateTo   结束时间
//     * @return
//     */
//    @Query(countQuery = " SELECT log.eventTypeCd,count(log)" +
//            "FROM BccUserBonusLog log " +
//            "WHERE log.openId = :openId " +
//            "AND log.eventDate>:dateFrom " +
//            "AND log.eventDate <:dateTo GROUP BY log.eventTypeCd")
//    List<Object[]> getWaitReceiveBonus(@Param("openId") String openId, @Param("dateFrom") Date dateFrom, @Param("dateTo") Date dateTo);

//    @Query("" +
//            "SELECT config.eventTypeCd,COUNT(log.id) from BccUserBonusLog log JOIN BccUserBonusLog.config config WHERE config.bonus_times > 0 GROUP BY BccUserBonusLog.config" +
//            "")
//    List<BccUserBonusConfig> group();
}
